package com.gilgamesh.mall.reptile.controller;

import com.gilgamesh.mall.reptile.bean.JDPrice;
import com.gilgamesh.mall.reptile.bean.R;
import com.gilgamesh.mall.reptile.service.ReptileService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author yanm
 * @date 2021/1/18 11:25
 **/
@RestController
@RequestMapping("api/reptile")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ReptileController {

    private final ReptileService reptileService;

    @PostMapping("getUrlEncode")
    public String decode(String keyWord){
        return reptileService.urlEncode(keyWord);
    }

    @GetMapping("getUrl")
    public String getUrl(String keyWord,Integer page){
        return reptileService.getUrl(keyWord,page);
    }


    @PostMapping("get")
    public List<R> getResponse(@RequestParam(value = "keyWord")String keyWord,
                               @RequestParam(value = "page") Integer page) {
        return reptileService.getResponse(keyWord,page);
    }

    @PostMapping("price")
    public JDPrice getPrice(String skuId){
        return reptileService.getPrice(skuId);
    }


}
